<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 无重复字符串的排列组合 -->
    <script>
      var permutation = S => {
        if (!S.length) return ['']
        let res = []
        // path是组合的字符串
        let search = path => {
          if (path.length === S.length) {
            // 长度满足条件，推入res数组
            res.push(path)
            return
          }
          for (let s of S) {
            // 将路径中没出现过的字母，拼接到路劲，再次组合
            if (path.indexOf(s) === -1) {
              search(`${path}${s}`)
            }
          }
        }
        // 从空字符串开始
        search('')
        return res
      }
      console.log(permutation('qwe'))
    </script>
  </body>
</html>
